use rbatis::rbdc::datetime::DateTime;
use rocket::serde::{Serialize,Deserialize};
use crate::RB;

crud!(Order{});
#[derive(Serialize,Deserialize,Clone,Debug)]
pub struct Order{
    pub id:Option<u32>,
    pub user_id:Option<u32>,
    pub carts_id:Option<String>,
    pub time:Option<DateTime>,
}

impl Order{
    pub async fn select_by_user_id(user_id:u32)->Vec<Order>{
        let mut rb = RB.clone();
        let query = rb.query_decode("select * from `order` where user_id = ?", vec![rbs::to_value!(user_id)]).await.unwrap();
        query
    }
}